import os
import csv

from base_class import MyBase

RECEIVE_PATH='/home/zhangle/etl/data/original/'

class AbsFile(MyBase):
    def __init__(self):
        MyBase.__init__(self)
        self.abs_header = {}
        self.abs_list = []
            
    def parse_from_file(self, abs_file):
        abs_file = os.path.join(RECEIVE_PATH,abs_file)
        with open(abs_file, 'rb') as csvfile:
            for row in csv.reader(csvfile, delimiter=','):
                if len(self.abs_header) is 0:
                    self.abs_header['name'] = row[0]
                    self.abs_header['size'] = row[1]
                    self.abs_header['create_time'] = row[2]
                    self.abs_header['md5'] = row[3]
                    self.abs_header['cnt'] = row[4]
                    continue
                abs_info = {}
                abs_info['name']        = row[0]
                abs_info['size']        = row[1]
                abs_info['create_time'] = row[2]
                abs_info['md5']         = row[3]
                self.abs_list.append(abs_info)
            pass
        pass

if __name__ == '__main__':
    abs = AbsFile()
    abs.parse_from_file('ii_2015_11_13.abs')
    print abs.abs_header
    print abs.abs_list
